package com.barbeque.mall.controller.admin.comment;

import com.barbeque.mall.bean.BaseRespVo;
import com.barbeque.mall.bean.BaseRespVoNoData;
import com.barbeque.mall.bean.comment.MarketComment;
import com.barbeque.mall.bean.comment.bo.CommentListBO;
import com.barbeque.mall.bean.param.CommonData;
import com.barbeque.mall.service.admin.comment.AdminCommentService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @author Euphonium
 * @since 2022/07/19
 */
@RestController
@RequestMapping("admin/comment")
public class AdminCommentController {

    @Autowired
    AdminCommentService adminCommentService;

    /**
     * admin/comment/list 商品评论(用户id/商品id)
     *
     * @param commentListBO
     * @return com.barbeque.mall.bean.BaseRespVo
     * @author Euphonium
     * @since 2022/07/19
     */
    @RequiresPermissions("admin:comment:list")
    @GetMapping("list")
    public BaseRespVo listComments(CommentListBO commentListBO) {
        CommonData<MarketComment> data = adminCommentService.listComments(commentListBO);
        return BaseRespVo.ok(data);
    }

    /**
     * admin/comment/delete 删除评论
     *
     * @param marketComment
     * @return com.barbeque.mall.bean.BaseRespVoNoData
     * @author Euphonium
     * @since 2022/07/19 21:30
     */
    @RequiresPermissions("admin:comment:delete")
    @PostMapping("delete")
    public BaseRespVoNoData deleteComment(@RequestBody MarketComment marketComment) {
        adminCommentService.deleteComment(marketComment);
        return BaseRespVoNoData.ok();
    }
}
